/**
 * Created by xiaom on 2016/10/30.
 */
import React, {Component, PropTypes} from 'react';
import {shouldUpdate} from '../../components/index';
import PureRenderMixin from 'react-addons-pure-render-mixin';

class Toast extends Component {

  constructor(props) {
    super(props);
    this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
  }

  static propTypes = {
    icon: PropTypes.string,
    message: PropTypes.string,
    show: PropTypes.bool
  };

  static defaultProps = {
    icon: 'weui-loading',
    message: '',
    show: false
  };

  shouldComponentUpdate(nextProps = {}, nextState = {}) {
    return shouldUpdate(this, nextProps, nextState);
  }

  render() {
    const {icon, show, message} = this.props;
    return (
      <div style={{display: show ? 'block' : 'none'}}>
        <div className="weui-mask_transparent"></div>
        <div className="weui-toast">
          <i className={icon + " weui-icon_toast"}></i>
          <p className="weui-toast__content">{message}</p>
        </div>
      </div>
    );
  }
}

export default Toast;
